#include "prog.h"

bool IntExpr::operator==(Expr &other){
    Expr* t = &other;
    if(typeid(*t) == typeid(IntExpr)){
        if(((IntExpr*)t)->i == ((IntExpr*)this)->i){ return true; }
        else{ return false; }
    }
    else{
        return false;
    }
}
bool VarExpr::operator==(Expr &other){
    Expr* t = &other;
    if(typeid(*t) == typeid(VarExpr)){
        if(strcmp((((VarExpr*)t)->x),(((VarExpr*)this)->x)) == 0){
            return true;
        }
        else{
            return false;
        }
    }
    else{
        return false;
    }
}
/*bool SelectExpr::operator==(Expr &other){
    Expr* t = &other;
    if(typeid(*t) == typeid(SelectExpr)){
        //if(strcmp((((SelectExpr*)t)->n), (((SelectExpr*)this)->n)) == 0){
        if(((SelectExpr*)t)->a == ((SelectExpr*)this)->a && ((SelectExpr*)t)->i == ((SelectExpr*)this)->i){
            return true;
        }
        else{
            return false;
        }
    }
    else{
        return false;
    }
}
bool SelectExpr::IsTheSameArray(Expr &other){
    Expr* t = &other;
    if(typeid(*t) == typeid(SelectExpr)){
        //if(strcmp((((SelectExpr*)t)->n), (((SelectExpr*)this)->n)) == 0){
        if(((SelectExpr*)t)->a == ((SelectExpr*)this)->a){
            return true;
        }
        else{
            return false;
        }
    }
    else{
        return false;
    }
}

bool StoreExpr::operator==(Expr &other){
    Expr* t = &other;
    if(typeid(*t) == typeid(StoreExpr)){
        if(((StoreExpr*)t)->a ==  ((StoreExpr*)this)->a && \
           ((StoreExpr*)t)->i ==  ((StoreExpr*)this)->i && \
           ((StoreExpr*)t)->e ==  ((StoreExpr*)this)->e ){
            return true;
        }
        else{
            return false;
        }
    }
    else{
        return false;
    }
}*/

bool BinExpr::operator==(Expr &other){
    Expr* t = &other;
    if(typeid(*t) == typeid(BinExpr)){
        if(*(((BinExpr*)t)->e1) == *(((BinExpr*)this)->e1) && *(((BinExpr*)t)->e2) == *(((BinExpr*)this)->e2)){
            return true;
        }
        else{
            return false;
        }
    }
    else{
        return false;
    }
}

bool BoolProp::operator==(Prop &other){
    Prop *t = &other;
    if(typeid(*t) == typeid(BoolProp)){
        if(((BoolProp*)t)->b == ((BoolProp*)this)->b){ return true;  }
        else{ return false; }
    }
    else{ return false;  }
}
bool NegProp::operator==(Prop &other){
    Prop *t = &other;
    if(typeid(*t) == typeid(NegProp)){
        if(*(((NegProp*)t)->p) == *(((NegProp*)this)->p)){ return true;  }
        else{ return false;  }
    }
    else{ return false; }
}
bool BinProp::operator==(Prop &other){
    Prop *t = &other;
    if(typeid(*t) == typeid(BinProp)){
        if((*(((BinProp*)t)->p1) == *(((BinProp*)this)->p1)) && (*(((BinProp*)t)->p2) == *(((BinProp*)this)->p2))){
            return true;
        }
        else{
            return false;
        }
    }
    else{
        return false;
    }
}
bool InequProp::operator==(Prop &other){
    Prop *t = &other;
    if(typeid(*t) == typeid(InequProp)){
        if(*(((InequProp*)t)->e1) == *(((InequProp*)this)->e1) && *(((InequProp*)t)->e2) == *(((InequProp*)this)->e2)){
            return true;
        }
        else{
            return false;
        }
    }
    else{
        return false;
    }
}
/*bool QuantProp::operator==(Prop &other){
    Prop *t = &other;
    if(typeid(*t) == typeid(QuantProp)){
        if(*(((QuantProp*)t)->p) == *(((QuantProp*)this)->p) && ((QuantProp*)t)->t == ((QuantProp*)this)->t){
            return true;
        }
        else{
            return false;
        }
    }
    else{
        return false;
    }
}*/

